package com.xxy.book.controller;

import com.xxy.book.form.LoginForm;
import com.xxy.book.form.RegisterForm;
import com.xxy.book.service.UserService;
import com.xxy.book.vo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author Xu XianYun
 * @Date 2022-12-27
 * @Description
 */
@RestController
public class UserHandler {

    @Resource
    private UserService userService;

    @PostMapping("/register")
    public Result register(RegisterForm registerForm) {
        return this.userService.register(registerForm);
    }

    @PostMapping("/login")
    public Result login(LoginForm loginForm) {
        return this.userService.login(loginForm);
    }

    @GetMapping("/activation/{userId}/{code}")
    public Result activation(@PathVariable("userId") Integer userId, @PathVariable("code") String code) {
        return userService.activation(userId, code);
    }
}
